<?php

namespace  Helper;

class Config
{
    private static $instance;
    private  $table;

    public static function getInstance(){
        if(self::$instance){
            return self::$instance;
        }else{
            self::$instance = new self();
            return  self::$instance;
        }
    }


    public function register(){

        $systemConfig = include ROOT_PATH . "/Config/main.php";
        $table = new \Swoole\Table(1024);
        $table->column('config', \Swoole\Table::TYPE_STRING, 1024*1024);       //1,2,4,8
        $table->create();
        $table->set('sysConfig',['config'=> json_encode($systemConfig)]);
        $this->table = $table;

    }

    public function get($key){

        return json_decode($this->table->get('sysConfig')['config'],true)[$key];
    }
}